{% extends "base.html" %}

{% block title %}电力报表{% endblock %}

{% block content %}
<div class="container mt-4">
    <h2>输入输出电力活动数据和排放因子数据一览表</h2>
    
    <div class="mb-3">
        <div class="btn-group">
            <a href="{{ url_for('report_power.export', format='excel') }}" class="btn btn-success">导出Excel</a>
            <a href="{{ url_for('report_power.export', format='word') }}" class="btn btn-primary">导出Word</a>
            <a href="{{ url_for('report_power.export', format='pdf') }}" class="btn btn-danger">导出PDF</a>
        </div>
    </div>
    
    <table class="table table-bordered">
        <thead>
            <tr>
                <th rowspan="2">项目</th>
            </tr>
            <tr>
                <th>电量(MWh)</th>
                <th>排放因子(tCO₂/MWh)</th>
                <th>排放量(tCO₂)</th>
            </tr>
        </thead>
        <tbody>
            {% if report_data %}
                {% for item in report_data %}
                <tr>
                    <td>{{ '购入' if item.purchase_mwh else '输出' }}</td>
                    <td>{{ item.purchase_mwh if item.purchase_mwh else item.output_mwh }}</td>
                    <td>{{ item.purchase_factor if item.purchase_mwh else item.output_factor }}</td>
                    <td>{{ item.purchase_emission if item.purchase_mwh else item.output_emission }}</td>
                </tr>
                {% endfor %}
            {% endif %}
        </tbody>
    </table>
</div>
{% endblock %}